#ifndef _FIBER_H_
#define _FIBER_H_

#include "object.h"
/*
* Cooperative multitasking through fiber functions.	
*/


struct Fiber_struct;
typedef struct Fiber_struct * Fiber;

struct Schedule_struct;
typedef struct Schedule_struct * Schedule;

#define SCHEDULE_FIBER_MAX 100

struct Schedule_struct {
	Fiber fibers[SCHEDULE_FIBER_MAX];
	Fiber running;
	int last;
	int max;
	int active;
	/* How many fibers are still active */
};

enum Fiberstate_enum { FIBER_RUN, FIBER_SLEEP, FIBER_DONE }  ;
typedef enum Fiberstate_enum Fiberstate;

typedef Fiber (*Fiber_action)(Fiber fiber);

struct Fiber_struct {
	Schedule 		schedule;
	Fiber_action 	action;
	Fiberstate 		state;	
	void **			arguments;
	void *			result;
	void * 			local;
	
};






#endif
